// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
//
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.reports.editor.design.cmds;

import java.util.Map;

import org.dengues.designer.ui.editors.AbstractGEFCommand;
import org.dengues.reports.editor.design.models.RepTableDiagram;
import org.dengues.reports.editor.design.models.ReportsDiagram;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf Qiang.Zhang.Adolf@gmail.com 2008-1-29 qiang.zhang $
 * 
 */
public class CreateCommand extends AbstractGEFCommand {

    private Object parent;

    private Object after;

    private Map extendsData;

    private Object newObject;

    /**
     * Sets the newObject.
     * 
     * @param newObject the newObject to set
     */
    public void setNewObject(Object newObject) {
        this.newObject = newObject;
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com CreateCommand constructor comment.
     * 
     * @param extendedData
     */
    public CreateCommand(Map extendedData, Object newObject) {
        this.extendsData = extendsData;
        this.newObject = newObject;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.designer.ui.editors.AbstractGEFCommand#execute()
     */
    @Override
    public void execute() {
        if ((getParent() instanceof ReportsDiagram) && newObject instanceof RepTableDiagram) {
            ReportsDiagram diagram = (ReportsDiagram) getParent();
            RepTableDiagram newObject2 = (RepTableDiagram) newObject;
            diagram.addRepTableDiagram(newObject2);
            newObject2.fixRepTableColumnDiagram();
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.dengues.designer.ui.editors.AbstractGEFCommand#undo()
     */
    @Override
    public void undo() {

    }

    /**
     * Getter for parent.
     * 
     * @return the parent
     */
    public Object getParent() {
        return this.parent;
    }

    /**
     * Sets the parent.
     * 
     * @param parent the parent to set
     */
    public void setParent(Object parent) {
        this.parent = parent;
    }

    /**
     * Getter for after.
     * 
     * @return the after
     */
    public Object getAfter() {
        return this.after;
    }

    /**
     * Sets the after.
     * 
     * @param after the after to set
     */
    public void setAfter(Object after) {
        this.after = after;
    }

}
